package com.yang.paymentdemo.controller;

import com.yang.paymentdemo.entity.Product;
import com.yang.paymentdemo.service.ProductService;
import com.yang.paymentdemo.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author yxc
 * @date 2022/1/19
 **/

@CrossOrigin  //开发前端的跨域访问
@Api(tags="商品管理")
@RestController
@RequestMapping("/api/product")
public class ProductController {


    @Resource
    private ProductService productService;


    @ApiOperation("测试接口")
    @GetMapping("/test")
    public R test(){

        return R.ok().data("message","hello").data("now",new Date());
    }

    @ApiOperation("简单查询接口")
    @GetMapping("/list")
    public R list(){
        List<Product> list = productService.list();
        return R.ok().data("productList",list);  //productList用于返回给前端接收数据
    }


}
